package com.jiesen.base.utils;

import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class ObjectToMap {

    public static HashMap<String, Object> to(Object obj) {
        HashMap hashMap = JSONObject.parseObject(JSON.toJSONString(obj), HashMap.class);
        return hashMap;
    }
    
    private static Pattern humpPattern = Pattern.compile("[A-Z]");
    public static String humpToLine2(String str) {
        Matcher matcher = humpPattern.matcher(str);
       StringBuffer sb = new StringBuffer();
       while (matcher.find()) {
            matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());
        }
         matcher.appendTail(sb);
       return sb.toString();
   }
}
